package com.lx.pc.restful.ldx;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.lx.pc.domain.vo.join.JoinVo;
import com.lx.pc.restful.util.AjaxResult;
import com.lx.pc.service.join.IJoinService;

/**
 * 绿大侠公众号
 * @author houzhong
 *
 */
@Controller
@RequestMapping("/wx")
public class HomeController {
	
	/**
	 * 加盟申请
	 * @return
	 */
	@Resource(name = "joinService")
	private IJoinService joinService;

	@RequestMapping("/toLdxHome")
	public ModelAndView toLdxHome() {
		ModelAndView mv = new ModelAndView("/ldx/home");
		return mv;
	}
	
	@RequestMapping("/toLdxJoined")
	public ModelAndView toLdxJoined() {
		ModelAndView mv = new ModelAndView("/ldx/joined");
		return mv;
	}
	@ResponseBody
	@RequestMapping("/saveJoin")
	public AjaxResult<String> saveJoin(JoinVo v,
			@RequestParam(value = "businessTypeStr[]")String[] businessTypeStr){
		AjaxResult<String> ajaxResult = new AjaxResult<String>();
		String type = "";
		for (String str : businessTypeStr) {
			type += str + ",";
		}
		v.setBusinessType(type);
		joinService.save(v);
		ajaxResult.setMsg("1");
		
		return ajaxResult;
	}
}
